/* ================================================
全局设置
================================================ */
var baseUrl = "https://www.erplus.co"

var baseDistance = 0 //滑动基数
var moveDistance = 5 //滑动距离

var reportStopTime = 10000 //报道停留时间
var currentReportImg = 0 //目前轮播的报道
var isFirstLoop = true //目前是否在第一个报道
var tempIndex = 0 //暂存报道index
var isUserClick = false //报道是否为用户点击
var reportTimeout //报道的定时器

var isAnimated = true //预约演示是否正在播放动画(增强用户体验)
var isHandUp = false //手是否位于上方

var midNum //验证码返回mid值
var waitTime = 60 //默认验证码等待时间
var codeDialogIndex = 0 //验证码弹窗index
// 手机号码验证
jQuery.validator.addMethod("isMobile", function (value, element) {
    var length = value.length
    var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9}||(0[0-9]{10})|(1[0-9]{10}))$/
    return this.optional(element) || (mobile.test(value))
}, "请正确填写您的手机号码")
var cookieUtil = {
    set: function (name, value, expires, path, domain, secure) {
        var cookieText = encodeURIComponent(name) + '=' +
            encodeURIComponent(value)
        if (expires instanceof Date) {
            cookieText += ';expires=' + expires.toGMTString()
        }
        if (path) {
            cookieText += ';path=' + path
        } else {
            cookieText += ';path=/'
        }
        if (domain) {
            cookieText += ';domain=' + domain
        }
        if (secure) {
            cookieText += ';secure'
        }
        document.cookie = cookieText
    },
    get: function (name) {
        var cookieName = encodeURIComponent(name) + '=',
            cookieStart = document.cookie.indexOf(cookieName),
            cookieValue = null
        if (cookieStart > -1) {
            var cookieEnd = document.cookie.indexOf(';', cookieStart)
            if (cookieEnd == -1) {
                cookieEnd = document.cookie.length
            }
            cookieValue = document.cookie.substring(cookieStart + cookieName.length, cookieEnd)
            try {
                cookieValue = decodeURIComponent(cookieValue)
            } catch (e) {
                cookieValue = document.cookie.substring(cookieStart + cookieName.length, cookieEnd)
            }

        }
        return cookieValue
    },
    unset: function (name, path, domain, secure) {
        this.set(name, '', '0', path, domain)
    }
}
$(document).ready(function () {
    /* ================================================
    初始设置
    ================================================ */
    $("html, body").scrollTop(0).animate({
        scrollTop: 0
    }, 100)
    $('.container-first-imgs-group').height($('.container-first').outerHeight(true)) //动态设置图片宽高，以适应safari
    window.onresize = function(){ 
        $('.container-first-imgs-group').height($('.container-first').outerHeight(true))
    }
    /* ================================================
    滚动设置
    ================================================ */
    var beforeNum = 0
    window.onscroll = function (info) {
        var top = document.documentElement.scrollTop || document.body.scrollTop //获取距离页面顶部的距离
        var imgs = $('.container-first-img')
        var difference = top - beforeNum
        if (difference > 0) { //向下滚动
            if (top > 60) {
                baseDistance = baseDistance + moveDistance
                imgs[0].style.transform = 'rotate(45deg)  translateZ(0)  translate(50px,' + (-200 - baseDistance) + 'px)'
                imgs[1].style.transform = 'rotate(-45deg) translateZ(0)   translate(321px,' + (412 + baseDistance) + 'px)'
                imgs[2].style.transform = 'rotate(45deg)  translateZ(0)  translate(290px,' + (60 + baseDistance) + 'px)'
            }
        } else if (difference < 0 && top < 650) { //向上滚动
            baseDistance = 0
            imgs[0].style.transform = 'rotate(45deg)  translateZ(0)  translate(50px,-200px)'
            imgs[1].style.transform = 'rotate(-45deg)  translateZ(0)  translate(321px,412px)'
            imgs[2].style.transform = 'rotate(45deg)  translateZ(0)  translate(290px,60px)'
        }
        beforeNum = top

        if (top >= 3000 && top <= 3500) { //预约演示logo动画
            if (isAnimated) {
                $('.container-six .container-six-right img:nth-child(1)').addClass('animated rubberBand')
                isAnimated = false
            }
        }
    }
    /* ================================================
    轮播设置
    ================================================ */
    var imgList = [{
        imgUrl: '/mp/index-resources/imgs/task-system.png', //任务
    }, {
        imgUrl: '/mp/index-resources/imgs/crm-system.png', //crm
    }, {
        imgUrl: '/mp/index-resources/imgs/performance-system.png', //绩效
    }, {
        imgUrl: '/mp/index-resources/imgs/approval-system.png', //审批
    }, {
        imgUrl: '/mp/index-resources/imgs/attendance-system.png', //考勤
    }]

    $('.container-third-img-box').fade({
        url: imgList,
        boxWid: 690,
        boxHei: 551,
        times: 1000000,
    }).css({
        margin: '0 auto',
        'z-index': 10
    })
    /* ================================================
    奖项设置
    ================================================ */
    var prizeList = [{
        name: '中国大数据与人工智能创新创业大赛（深圳）',
        prize: '三等奖',
    }, {
        name: '首届全球潮人创新创业大赛·深圳赛区城市决赛',
        prize: '优胜奖',
    }, {
        name: '第二届99°海外学人创新创业大赛广州预选赛',
        prize: '冠军',
    }, {
        name: '中国（深圳）创新创业大赛成果转化双创赛赛区总决赛',
        prize: '企业组二等奖',
    }, {
        name: '2016年秘鲁APEC·CEO峰会',
        prize: '中国创新型企业代表',
    }, {
        name: '德勤·2016深圳明日之星企业',
        prize: '',
    }, {
        name: '2016年度最具投资价值项目50强',
        prize: '',
    }, {
        name: '第三届移动互联网大赛',
        prize: '季军',
    }, {
        name: 'APEC未来之声NOVO青年创新者大赛',
        prize: 'TOP4',
    }, {
        name: '东沙湖杯·千人计划创业大赛 华南赛区',
        prize: 'TOP5',
    }, {
        name: '2016互联网创业最佳雇主',
        prize: '',
    }, {
        name: '第二届全球APP开发创意争霸赛总决赛',
        prize: '优秀奖',
    }, {
        name: '搜狐·中国创客专业先锋',
        prize: '',
    }]

    for (var i = 0; i < prizeList.length; i++) {
        $('.container-fourth-left').append('<div class="font-18 name">' + prizeList[i].name + '<p class="prize">' + prizeList[i].prize + '</p></div>')
    }
    /* ================================================
    媒体报道
    ================================================ */
    var reportList = [{
        imgUrl: '/mp/index-resources/imgs/report1.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report2.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report3.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report4.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report5.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report6.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report7.png',
    }, {
        imgUrl: '/mp/index-resources/imgs/report8.png',
    }]
    for (var i = 0; i < reportList.length; i++) {
        if (i === 0) {
            $('.container-five .imgs-group').append('<img class="box-shadow" src="' + reportList[i].imgUrl + '" onclick="clickReport(this,' + i + ',' + reportList.length + ')">')
            continue
        }
        $('.container-five .imgs-group').append('<img src="' + reportList[i].imgUrl + '" onclick="clickReport(this,' + i + ',' + reportList.length + ')">')
    }

    $('.container-five .imgs-group img').slice(3, reportList.length).css({
        "margin-top": "20px",
    })

    /* ================================================
    预约演示设置
    ================================================ */
    window.setInterval(function () {
        $('.container-six .container-six-right img:nth-child(1)').removeClass('rubberBand')
        isAnimated = true
    }, 5000);

    window.setInterval(function () {
        if (isHandUp) {
            $('.container-six .container-six-right img:nth-child(3)').rotate({
                center: ["0%", "30%"],
                animateTo: 0
            })
            isHandUp = false
        } else {
            $('.container-six .container-six-right img:nth-child(3)').rotate({
                center: ["0%", "30%"],
                animateTo: -25
            })
            isHandUp = true
        }
    }, 2000)

    /* ================================================
    提交预约信息
    ================================================ */
    //验证信息
    $(".container-six-left-form").validate({
        rules: {
            name: {
                required: true,
            },
            phone: {
                required: true,
                minlength: 11,
            },
            describe: {
                required: true,
            }
        },
        messages: {
            name: {
                required: "请填写姓名",
            },
            phone: {
                required: "请填写手机号",
                minlength: "请正确填写您的手机号码",
            },
            describe: {
                required: "请填写描述",
            }
        },
        submitHandler: function (form) {
            var name = $('.container-six-left-form .name-box input').val()
            var phone = $('.container-six-left-form .phone-box input').val()
            var describe = $('.container-six-left-form .textarea-box textarea').val()
            var param = {
                name: name,
                phoneNum: phone,
                companyInfo: describe,
            };
            $.ajax({
                url: 'https://www.plusmoney.cn/feedback/MpBespoke',
                type: 'POST',
                dataType: 'JSON',
                data: JSON.stringify(param),
                success: function (data) {
                    if (data.result == '0') {
                        $('.container-six-left-form .name-box input').val('');
                        $('.container-six-left-form .phone-box input').val('');
                        $('.container-six-left-form .textarea-box textarea').val('');
                        layer.msg('预约演示成功！')
                    } else {
                        layer.msg('预约演示失败！')
                    }
                }
            })
        }
    })

    /* ================================================
    其它设置
    ================================================ */
    $('.nav-bar .nav-login .login-info-box p').click(function () {
        window.open(baseUrl + '/mp/erplus/index.html#/')
    })

    changeReport(reportList.length) //报道轮播
    getUserInfo() //获取用户信息

})

/* ================================================
弹窗相关方法
================================================ */
var videoDialog = function (index) {
    var linkList = [{
        link: 'https://player.youku.com/embed/XMzE2MzQyMzYyMA=='
    }, {
        link: 'http://player.youku.com/embed/XMzI5Mjc5Mzc2OA=='
    }, {
        link: 'https://player.youku.com/embed/XMzE2NTQ1NjQxNg=='
    }, {
        link: 'https://player.youku.com/embed/XMzE2MzQ5NjQ5Ng=='
    }, {
        link: 'https://player.youku.com/embed/XMzA0ODY0MDQ4OA=='
    }]
    var useLink = linkList[index].link
    layer.open({
        type: 1,
        resize: false,
        title: false,
        area: ['985px', '600px'],
        //content: '<iframe style="width:1283px;height:670px" src="' + useLink + '" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen></iframe>', //哔哩哔哩
        //content: '<iframe style="width:988px;height:635px" src="' + useLink + '" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen></iframe>', //腾讯
        content: '<iframe style="width:988px;height:610px" src="' + useLink + '" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen></iframe>', //优酷
        move: false,
        scrollbar: false,
    })
}

var downloadApp = function () {
    layer.open({
        type: 1,
        resize: false,
        title: ['<img src="/mp/index-resources/imgs/logo-big.png">', 'background-color: #FFFFFF;border-bottom: 0'],
        area: ['550px', '380px'],
        content: '<section class="downloadApp-box"><img src="/mp/index-resources/imgs/pic-qr.png"><p class="font-18">微信扫一扫即可下载大管加</p></section>',
        move: false,
        scrollbar: false,
    })
}

var loginDialog = function () {
    var getBrowerType = browserType()
    if (getBrowerType === 'IE') {
        layer.open({
            type: 1,
            resize: false,
            title: ['十分抱歉', 'font-size:16px;'],
            move: false,
            scrollbar: false,
            area: ['500px', '300px'],
            content: '<section>'+
            '<div class="suggest-dialog">'+
            '<div class="suggest">本功能暂不支持您目前使用的浏览器，为了使您拥有更好的体验：</div>'+
                '<p class="suggest-red">我们强烈建议您更换当前浏览器，</p>'+
                '<p class="suggest-link">'+
                    '我们推荐使用<a href="http://www.firefox.com.cn/" target="_blank">火狐浏览器</a>或<a href="http://www.google.cn/chrome/browser/desktop/index.html" target="_blank">Chrome浏览器</a>'+
                '</p>'+
            '</div>'+
            '</section>',
            cancel: function () {
               return
            },
        })
        return
    }
    layer.open({
        type: 1,
        resize: false,
        title: ['登录', 'background-color: #FFFFFF;border-bottom: 0;font-size:20px;'],
        area: ['470px', '380px'],
        content: '<section><div class="login-box"><form class="login-form">' +
            '<input name="phone" class="phone" type="text" placeholder="请输入手机号">' +
            '<input name="password" class="password" type="password" placeholder="请输入密码">' +
            '<div class="error-message"></div>' +
            '<div class="check-box"><div class="remberme-box"><input id="remberme" class="remberme" type="checkbox"> 记住账号<p></p></div>' +
            '<a class="go-register" onclick="codeLoginDialog()">还未设置密码?</a></div>' +
            '<button  class="btn btn-default login-submit" onclick="login()">登录</button>' +
            '</form>' +
            '</div>' +
            '</section>',
        scrollbar: false, //屏蔽滚动
        move: false
    })
    if (localStorage.username != null && localStorage.username != 'null' && localStorage.username != 'undefined') {
        $(".login-box .login-form .check-box .remberme-box .remberme").attr("checked", true);
        $(".login-box .login-form .phone").val(localStorage.username);
    }
}

// 手机验证码登录框
var codeLoginDialog = function () {
    layer.closeAll()
    setTimeout(function () {
        layer.open({
            type: 1,
            resize: false,
            title: ['登录', 'background-color: #FFFFFF;border-bottom: 0;font-size:20px;'],
            area: ['470px', '350px'],
            content: '<section><div class="login-box">' +
                '<form class="login-form code-login">' +
                '<input name="phone" class="phone" type="text" placeholder="请输入手机号">' +
                '<div class="code-box">' +
                '<input name="code" class="code" type="text" placeholder="请输入验证码" maxlength="10">' +
                '<a class="get-code" onclick="getCodeDialog()">获取验证码</a>' +
                '</div>' +
                '<div class="error-message"></div>' +
                '<button  class="btn btn-default code-login-submit" onclick="codeLogin()">登录</button>' +
                '</form>' +
                '</div>' +
                '</section>',
            move: false,
            scrollbar: false,
        })
    }, 500)
}

// 验证码弹框
var getCodeDialog = function () {
    if ($('.login-box .code-login .phone').val() === '' || $('.login-box .code-login .phone').val() === ' ') {
        $('.login-form .error-message').text('请填写手机号码')
        setTimeout(function () {
            $('.code-login .error-message').text('')
        }, 10000)
        return
    }
    codeDialogIndex = layer.open({
        type: 1,
        resize: false,
        title: ['图形验证码', 'background-color: #FFFFFF;border-bottom: 0;font-size:16px;'],
        area: ['330px', '140px'],
        closeBtn: 0,
        content: '<section>' +
            '<div class="code-box">' +
            '<div class="input-group">' +
            '<img src="https://www.erplus.co/mpsms/getImageVerifyCode" onclick="changeCodeImg()" class="auth-code">' +
            '<input type="text" class="form-control" placeholder="请输入左侧图形验证码">' +
            '</div>' +
            '<div class="button-group">' +
            '<button class="btn btn-default" onclick="codeBoxConfirm()">确定</button>' +
            '<button class="btn btn-default" onclick="codeBoxCancel()">取消</button>' +
            '</div>' +
            '</div>' +
            '</section>',
        move: false,
        scrollbar: false,
    })
}

var changeCodeImg = function () {
    $('.code-box .input-group img').attr('src', 'https://www.erplus.co/mpsms/getImageVerifyCode?' + Math.random())
}

var codeBoxConfirm = function () {
    var phoneNum = $('.code-login .phone').val()
    var code = $('.code-box .input-group input').val()
    if (code === '' || code === ' ') {
        layer.msg('请输入验证码', {
            time: 1000,
        })
    } else {
        var dataToSend = 'code=' + code + '&needmsg=1&phoneNumber=' + phoneNum
        $.ajax({
            type: "get",
            url: baseUrl + '/mpsms/checkImageVerifyCode',
            data: dataToSend,
            withCredentials: true,
            headers: {
                "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
            },
            success: function (data) {
                var resultData = JSON.parse(data)
                if (resultData.result == 0) {
                    midNum = resultData.mid
                    countDown()
                } else {
                    changeCodeImg()
                    layer.msg('验证码错误', {
                        time: 1000,
                    })
                }
            }
        })
    }
}

var codeBoxCancel = function () {
    layer.close(codeDialogIndex)
}

/* ================================================
登录方法
================================================ */
// 登录验证
var login = function () {
    //验证信息
    $(".login-form").validate({
        rules: {
            phone: {
                required: true,
                minlength: 11,
            },
            password: {
                required: true,
            }
        },
        messages: {
            phone: {
                required: "请填写手机号码",
                minlength: "请正确填写您的手机号码",
            },
            password: {
                required: "请填写密码",
            }
        },
        errorPlacement: function (error, element) {
            var errText = ""
            errText = error[0].innerText
            $('.login-form .error-message').text(errText)
            setTimeout(function () {
                $('.login-form .error-message').text('')
            }, 10000)
        },
        submitHandler: function (form) {
            var phoneNum = $('.login-form .phone').val()
            var password = $('.login-form .password').val()
            var url = baseUrl + "/oauth/v2/token?"
            url += "grant_type=password"
            url += "&webflag=1"
            url += "&client_id=2_3t7k61w8zz28wc00w0o0swgo0ko48w08c8csk4ss444os4ccgo"
            url += "&client_secret=6o596th97340soswgw8ssswk8gk8cwoo40c4wwccs4g4wswk8"
            url += "&username=" + phoneNum
            url += "&password=" + encodeURIComponent(password) + "%23%23%23PC"
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'JSON',
                success: function (data) {
                    if (typeof (data.access_token) != 'undefined') {
                        if ($('#remberme').is(':checked')) {
                            localStorage.username = phoneNum
                        }
                        LoginSuccess(data)
                    } else {
                        $('.login-form .error-message').text('手机或密码错误')
                    }
                },
                error: function () {
                    layer.msg('网络错误', {
                        time: 2000,
                    })
                }
            })
        }
    })
}

var codeLogin = function () {
    //验证信息
    $(".code-login").validate({
        rules: {
            phone: {
                required: true,
                minlength: 11,
            },
            code: {
                required: true,
            }
        },
        messages: {
            phone: {
                required: "请填写手机号码",
                minlength: "请正确填写您的手机号码",
            },
            code: {
                required: "请填写验证码",
            }
        },
        errorPlacement: function (error, element) {
            var errText = ""
            errText = error[0].innerText
            $('.code-login .error-message').text(errText)
            setTimeout(function () {
                $('.code-login .error-message').text('')
            }, 10000)
        },
        submitHandler: function (form) {
            if (typeof (midNum) != 'undefined') {
                var url = baseUrl + '/oauth/v2/token?grant_type=password&username='
                url += $('.code-login .phone').val()
                url += '&password='
                url += $('.code-login .code-box .code').val() + '%23%23%23PMC' + '%23%23%23' + midNum
                url += '&client_id=2_3t7k61w8zz28wc00w0o0swgo0ko48w08c8csk4ss444os4ccgo&client_secret=6o596th97340soswgw8ssswk8gk8cwoo40c4wwccs4g4wswk8'
                $.get(url, function (data) {
                    if (typeof (data.access_token) != "undefined") {
                        LoginSuccess(data)
                    } else {
                        $('.code-login .error-message').text('验证码错误')
                        setTimeout(function () {
                            $('.code-login .error-message').text('')
                        }, 10000)
                    }
                })
            } else {
                $('.code-login .error-message').text('验证码错误')
                setTimeout(function () {
                    $('.code-login .error-message').text('')
                }, 10000)
            }
        }
    })

    $('.code-login').submit(function () {})
}

var LoginSuccess = function (data) {
    cookieUtil.unset('token', '/', '.www.erplus.co')
    cookieUtil.unset('token', '/', '.erplus.co')
    cookieUtil.unset('nickname', '/', '.www.erplus.co')
    cookieUtil.unset('nickname', '/', '.erplus.co')
    cookieUtil.set('token', data.access_token, '-1', '/', '.www.erplus.co')
    cookieUtil.set('token', data.access_token, '-1', '/', '.erplus.co')
    cookieUtil.set('nickname', data.user.nickname, '-1', '/', '.erplus.co')
    cookieUtil.set('nickname', data.user.nickname, '-1', '/', '.www.erplus.co')
    getUserInfo()
    layer.closeAll()

    newTabUrl = baseUrl + '/mp/erplus/index.html#/';
    if (newTabUrl.length > 0) {
        window.location.href = newTabUrl;
    }
}

var loginOut = function () {
    cookieUtil.unset('token', '/', 'www.erplus.co')
    cookieUtil.unset('token', '/', '.erplus.co')
    cookieUtil.unset('token', '/', 'localhost')
    $('.nav-bar .nav-login .login-info-box').css({
        "display": "none",
    })
    $('.nav-bar .nav-login a:nth-child(1)').css({
        "display": "block",
    })
}

/* ================================================
报道相关方法
================================================ */
var clickReport = function (dom, index, length) {
    $('.container-five .report-box .report-content').stop(true, true)
    if (tempIndex === index && isUserClick) {
        return
    }
    if (index != currentReportImg) { //用户点击
        isUserClick = true
        tempIndex = index
        clearTimeout(reportTimeout)
        changeReport(length)
    }
    $('.container-five .imgs-group img').slice(0, length).removeClass('box-shadow')
    $(dom).addClass('box-shadow')
    if (index === 0) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://36kr.com/p/5080225.html" target="_blank"><p class="report-content font-24">加号科技用3年时间打磨一款产品，用OKR管理方法提升中小企业运转效率。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 1) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://fm.qq.com/show/rd001Hjdl50Cc3wv" target="_blank"><p class="report-content font-24">大管加将多个系统融合在一个系统当中，实现了用一个系统完成了整个公司的事情。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 2) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://www.chuangkem.com/archives/102918" target="_blank"><p class="report-content font-24">大管加把企业主和高管们从琐事中解放出来，让他们有时间专注于人、战略和资本。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 3) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="https://mp.weixin.qq.com/s?__biz=MzAwOTc5NzA3Nw==&mid=2652472268&idx=1&sn=b33f510e2c104fa812ed8b3f3e495d35&scene=1&srcid=0712Da9spM2JLZ5gajE0VLO5&key=77421cf58af4a6538b0fe52b6da3ed8e040d82ef3c09f10fcc5fc8524efe5b40737425485130311d8b2cdfb173e4a6c5&ascene=0&uin=Mzk1NTI1NDM1&devicetype=iMac+MacBook9%2C1+OSX+OSX+10.11.5+build" target="_blank"><p class="report-content font-24">大管加的强势切入，对早日迎来真正的企业移动工作时代意义极大。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 4) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a><p class="report-content font-24">和一些既会打鸣又会下蛋，但核心功能并不好用的SaaS平台相比，大管加更加专注，同时也有自己的独到理念和设计。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 5) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://www.pingwest.com/manager-plus-in-shenzhen/" target="_blank"><p class="report-content font-24">对于一个企业管理软件来说，大管加显得过于“剑走偏锋”，但是，“颠覆都是始于剑走偏锋”。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 6) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://www.plusmoney.cn/zxdt/mtbd/151.html" target="_blank"><p class="report-content font-24">大管加在保证企业层级有序的情况下，让领导充分了解下属，从而更好的做出决策。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    } else if (index === 7) {
        $('.container-five .report-box .report-content').fadeOut(500, function () {
            $('.container-five .report-box .report-content').empty()
            $('.container-five .report-box .report-content').append('<a href="http://m.lieyunwang.com/archives/177021" target="_blank"><p class="report-content font-24">大管加希望通过一系列的数据让企业管理者能更客观的对工作本身以及团队成员做出决策。</p></a>')
            $('.container-five .report-box .report-content').fadeIn(500)
        })
    }
    currentReportImg = index
    if (index === 0) {
        isFirstLoop = true
    }
}

var changeReport = function (length) {
    if (currentReportImg >= length - 1) {
        currentReportImg = 0
        isFirstLoop = false
    }
    reportTimeout =  setTimeout(function () {
        isUserClick = false
        if (isFirstLoop) {
            currentReportImg = currentReportImg + 1
        }
        $('.container-five .imgs-group img:nth-child(' + (currentReportImg + 1) + ')').click()
        changeReport(length)
    }, reportStopTime)
}


/* ================================================
其它方法
================================================ */
var goAppointment = function () {
    $("html, body").scrollTop(0).animate({
        scrollTop: ($('.container-six').offset().top) - 100
    }, 1000)
}

var getUserInfo = function () {
    token = cookieUtil.get('token')
    if (token === null) {
        return false
    }
    $.ajax({
        async: false,
        type: "post",
        url: baseUrl + '/userWeb/getUserInfo',
        dataType: "json",
        headers: {
            'Authorization': "Bearer " + token
        },
        success: function (data) {
            if (data.respCode === '000') {
                loadUserInfo(data)
            }
        },
        error: function () {
            layer.msg('登录失效！请重新登录！', {
                time: 2000,
            })
        }
    })
}

var loadUserInfo = function (data) {
    var avatarUrl = baseUrl + '/uploads/avatars' + data.item.imageName
    $('.nav-bar .nav-login .login-info-box img').attr('src', avatarUrl)
    $('.nav-bar .nav-login .login-info-box .user-name').text(data.item.name)
    $('.nav-bar .nav-login a:nth-child(1)').css({
        "display": "none",
    })
    $('.nav-bar .nav-login .login-info-box').css({
        "display": "block",
    })
}

var countDown = function () {
    var tempTime = waitTime
    layer.close(codeDialogIndex)
    $('.code-login .code-box a').removeAttr("onclick")
    $('.code-login .code-box a').text(tempTime + "秒后重发") // 防止刚关闭弹窗用户仍可点击
    var timer = setInterval(function () {
        tempTime -= 1
        if (tempTime > 0) {
            $('.code-login .code-box a').removeAttr("onclick")
            $('.code-login .code-box a').text(tempTime + "秒后重发")
        } else {
            clearInterval(timer)
            $('.code-login .code-box a').text("获取验证码")
            $('.code-login .code-box a').attr("onclick", "getCodeDialog();")

        }
    }, 1000)
}

// 浏览器判断
var browserType = function () {
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
    var isOpera = userAgent.indexOf("Opera") > -1;
    if (isOpera) {
        return "Opera"
    }; //判断是否Opera浏览器
    if (userAgent.indexOf("Firefox") > -1) {
        return "FF"
    } //判断是否Firefox浏览器
    if (userAgent.indexOf("Chrome") > -1) {
        return "Chrome"
    }
    if (userAgent.indexOf("Safari") > -1) {
        return "Safari"
    } //判断是否Safari浏览器
    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
        return "IE"
    } //判断是否IE浏览器
    if (!!window.ActiveXObject || "ActiveXObject" in window) {
        return "IE"
    } //判断是否IE 10,11浏览器
}

//清除所有cookie函数  
function clearAllCookie() {
    var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
    if (keys) {
        for (var i = keys.length; i--;)
            document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString()
    }
}